// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-10

package kind

// FinanceType
// 财务类型.
type FinanceType int

const (
	_ FinanceType = iota
	FinanceTypeIncome
	FinanceTypeExpense
)

var (
	financeTypeTexts = map[FinanceType]string{
		FinanceTypeIncome:  "收入",
		FinanceTypeExpense: "支出",
	}
	financeTypeTextUnknown = "未知"

	financeTypeFlags = map[FinanceType]string{
		FinanceTypeIncome:  "income",
		FinanceTypeExpense: "expense",
	}
	financeTypeFlagUnknown = ""
)

func FinanceTypeDict() []map[string]any {
	var res = make([]map[string]any, 0)
	for _, v := range []FinanceType{
		FinanceTypeIncome,
		FinanceTypeExpense,
	} {
		res = append(res, map[string]any{
			"Key":   v,
			"Value": v.Text(),
		})
	}
	return res
}

// Flag
// 标记.
func (o FinanceType) Flag() string {
	if flag, ok := financeTypeFlags[o]; ok {
		return flag
	}
	return financeTypeFlagUnknown
}

// Text
// 文本.
func (o FinanceType) Text() string {
	if text, ok := financeTypeTexts[o]; ok {
		return text
	}
	return financeTypeTextUnknown
}
